package com.party.admin.task;

import com.party.core.model.system.TargetType;
import com.party.core.service.collect.biz.SystemCollectBizService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @Description:
 * @Author: yangshoukun
 * @Date: 2018/6/29 11:38
 */
@Component
public class QuartzVisitCollect {
    @Autowired
    private SystemCollectBizService systemCollectBizService;

    private static Logger logger = LoggerFactory.getLogger(QuartzVisitCollect.class);

    public void saveRedisData() {
        try {
            // 写入platform
            systemCollectBizService.addOrNotPlatform(false);

            // 写入module
            Set<String> set = TargetType.convertSet();
            set.forEach(code -> systemCollectBizService.addOrNotModule(false, code));
        } catch (Exception e) {
            logger.error("定时将数据分析数据从redis写入mysql异常", e);
        }
    }
}
